void atomic(bool on) {
    static sigset_t oldmask;
    sigset_t newmask;
    if (on) {
       sigemptyset(&newmask);
       sigaddset(&newmask, SIGALRM); //the alarm signal
       sigaddset(&newmask, SIGINT); // the CNTRL-C
       sigaddset(&newmask, SIGUSR1); // the CRT signal
       sigaddset(&newmask, SIGUSR2); // the KB signal
       sigprocmask(SIG_BLOCK, &newmask, &oldmask);
    }
    else {
    //unblock the signals
       sigprocmask(SIG_SETMASK, &oldmask, NULL);
    }
}
